/**
 * Copyright 2015 jianglibo@gmail.com
 *
 */
package com.m3958.logcollector;

import java.io.IOException;
import java.nio.file.Path;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.m3958.logcollector.config.AppCacheConfig;
import com.m3958.logcollector.config.AppConfig;
import com.m3958.logcollector.repository.TreeBlobRepository;
import com.m3958.logcollector.service.NextSeqNumber;
import com.m3958.logcollector.tree.TreeHolder;
import com.m3958.logcollector.vo.JavaTypeHolder;

/**
 * @author jianglibo@gmail.com
 *         2016年1月14日
 *
 */
@Configuration
public class SomeBeanConfiger {

    @Autowired
    private AppConfig appConfig;

    @Autowired
    private AppCacheConfig appCacheConfig;

    @Autowired
    private TreeBlobRepository tbRepo;

    @Autowired
    private NextSeqNumber nextSeqNumber;

    @Autowired
    private ObjectMapper objectMapper;

    @Autowired
    private JavaTypeHolder javaTypeHolder;

    @Bean(name="mapValued")
    public TreeHolder<Map<String, String>> mapValuedTreeHolder() throws IOException {
        Path logFolder = appConfig.getWhlRootPath().resolve("tree-log");
        long maxTreeWeigher = appCacheConfig.getMaxTreeWeigher();
        return new TreeHolder<>(tbRepo, javaTypeHolder.getTreeMapStringString(), javaTypeHolder.getTuaMapStringString(), objectMapper, nextSeqNumber,
                logFolder, maxTreeWeigher);
    }
}
